<?php
	session_start();
	if($_SESSION['uid']==""||$_SESSION['level']!=2){
		header("Location: ./login.html");
		exit();
	}
	include('/php/tool/submitValidate.php');
	include('/php/tool/pdo.php');
	include('/php/bll/PublicDataBLL.php');
    include('/php/class/public-data.class.php');
    include('/php/class/student-information-register.class.php');
    include('/php/class/class-dormitory-management.class.php');
    include('/php/bll/ClassDormitoryManagementBLL.php');
    
	$major = isset($_GET['major']) ? (int)$_GET['major'] : 0;
	$grade = isset($_GET['grade']) ? (int)$_GET['grade'] : 0;
	$page = isset($_GET['page']) ? (int)$_GET['page'] : 0;
	$pageSize = isset($_GET['pageSize']) ? (int)$_GET['pageSize'] : 20;
    $search = isset($_GET['search']) ? $_GET['search'] : '';
	
	$publicData=new PublicDataBLL();
    $ClassDormitoryManagementBLL=new ClassDormitoryManagementBLL();
?>
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<!--[if lt IE 9]>
<script type="text/javascript" src="lib/html5shiv.js"></script>
<script type="text/javascript" src="lib/respond.min.js"></script>
<![endif]-->
<link rel="stylesheet" type="text/css" href="static/h-ui/css/H-ui.min.css" />
<link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/H-ui.admin.css" />
<link rel="stylesheet" type="text/css" href="lib/Hui-iconfont/1.0.8/iconfont.css" />
<link rel="stylesheet" type="text/css" href="static/h-ui.admin/skin/default/skin.css" id="skin" />
<link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/style.css" />
<!--[if IE 6]>
<script type="text/javascript" src="lib/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
<script src="./scripts/crypto-js/core.js"></script>
<script src="./scripts/crypto-js/md5.js"></script>
<title>学生宿舍管理</title>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 宿舍管理 
	<span class="c-gray en">&gt;</span> 学生宿舍分配 
	<a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" >
		<i class="Hui-iconfont">&#xe68f;</i>
	</a>
</nav>
<div class="page-container">
	<div class="cl pd-5 mybg-2 bk-gray"> 
		<span class="l"> 
			<a href="javascript:;" onclick="removeStudentDormCheckbox()" class="btn btn-danger radius">
				<i class="Hui-iconfont">&#xe6e2;</i> 清空选中
			</a> 
		</span> 
		<span class="r">
			<button onclick="removeIframe()" class="btn btn-primary radius">关闭选项卡</button>
		</span>
	</div>
	<div class="mt-10">
		<form action="class-dormitory-management.php" method="get" class="form-horizontal mybg-2 bk-gray pt-5 pb-5">
			<div class="row cl mb-5">
                <label class="form-label col-xs-1" style="width:80px;margin:0;padding:0;line-height:31px;">年级：</label>
				<div class="formControls col-xs-8 col-sm-2">
					<select id="grade" name="grade" class="select" size="1" style="height:31px">
					<option value="0">所有</option>
						<?php
							$gradeList=$publicData->getInstructorGradeList($_SESSION['uid']);
							foreach($gradeList as $myGrade){
								if($myGrade['grade']==$grade){
									echo '<option value="'.$myGrade['grade'].'" selected="">'.$myGrade['grade'].'</option>';
								}else{
									echo '<option value="'.$myGrade['grade'].'">'.$myGrade['grade'].'</option>';
								}
								
							}
							//$str='<option value="2">2</option>';
						?>
					</select>
				</div>
				<label class="form-label col-xs-1" style="width:80px;margin:0;padding:0;line-height:31px;">专业：</label>
				<div class="formControls col-xs-8 col-sm-3">
					<select id="major" name="major" class="select" size="1" style="height:31px">
					<option value="0">所有</option>
						<?php
							//获取专业列表
							$majorList=$publicData->getInstructorMajorList($_SESSION['uid']);
							foreach($majorList as $myMajor){
								if($myMajor['major_id']==$major){
									echo '<option value="'.$myMajor['major_id'].'" selected="">'.$myMajor['major_name'].'</option>';
								}else{
									echo '<option value="'.$myMajor['major_id'].'">'.$myMajor['major_name'].'</option>';
								}
							}
							//
						?>
					</select>
                </div>
                <button id="btn-search" class="btn btn-success" type="submit"><i class="Hui-iconfont">&#xe665;</i> 查找</button>
			</div>
		</form>
	</div>
	<table class="table table-border table-bordered table-hover table-bg mt-10">
		<thead>
			<tr>
				<th scope="col" colspan="7">学生住宿管理</th>
			</tr>
			<tr class="text-c">
				<th width="25"><input type="checkbox" value="" name=""></th>
				<th while="180">年级</th>
				<th width="230">专业</th>
				<th width="180">班级</th>
                <th while="180">总人数</th>
                <th while="180">已分配人数</th>
				<th width="70">操作</th>
			</tr>
		</thead>
		<tbody id="">
            <?php
				$result=$ClassDormitoryManagementBLL->getInstructorGradeMajorClassInfoList($_SESSION['uid'],$grade,$major);
				$infoList=$result['infoList'];
				foreach($infoList as $info){
					echo '<tr class="text-c"><td><input type="checkbox" value="" name="grade_major_checkbox"></td>
                    <td class="grade">'.$info['grade'].'</td>
					<td class="major_id" style="display:none">'.$info['major_id'].'</td>
					<td class="major_name">'.$info['major_name'].'</td>
                    <td class="class">'.$info['class'].'</td>
                    <td class="student_sum">'.$ClassDormitoryManagementBLL->getClassStudentSum($info['grade'],$info['major_id'],$info['class']).'</td>
                    <td class="student_allocated">'.$ClassDormitoryManagementBLL->getClassAllocatedDormStudentNumber($info['grade'],$info['major_id'],$info['class']).'</td>
                    <td><a title="编辑" href="javascript:;" onClick="creatIframe(\'student-dormitory-allocating.php?grade='.$info['grade'].'&major='.$info['major_id'].'&class='.$info['class'].'\',\'学生宿舍分配\');" style="text-decoration:none">
						<i class="Hui-iconfont">&#xe6df;</i></a>
						<a title="删除" href="javascript:;" onclick="removeDormitory(this)" class="ml-5" style="text-decoration:none">
						<i class="Hui-iconfont">&#xe6e2;</i></a>
                    </td></tr>';
				}
            ?>
            
		</tbody>
	</table>
	<div class="modal-footer">
		<!--<a class="btn" href=">上一页</a>
			<span><select  id="instructor_page" name="page" class="btn">
					//$option='<option value="0">1</option>';
					//$pageMax=$dormCenterBLL->getInstructorListPage((int)$status,(int)$major,(int)$grade,(int)$pageSize,$search);
					/*if($pageMax>0){
						for($i=0;$i<$pageMax;$i++){
							if($i==$page){//selected=""
								echo '<option value="'.$i.'" selected="selected">'.($i+1).'</option>';
							}else{
								echo '<option value="'.$i.'" ">'.($i+1).'</option>';
							}
						}
					}else{
						echo '<option value="0">1</option>';
					}*/
			</select>
		</span>
		<a class="btn" href="">下一页</a>-->
	</div>
</div>
</body>

<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="lib/jquery/1.9.1/jquery.min.js"></script> 
<script type="text/javascript" src="lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="static/h-ui/js/H-ui.min.js"></script> 
<script type="text/javascript" src="static/h-ui.admin/js/H-ui.admin.js"></script> <!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="scripts/class-dormitory-management.jquery.js"></script>
</body>
</html>